/*
    Android UIML

	Copyright (C) 2010  Bram Goffings (bramgoffings@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package uiml.android.elements.peers;

import java.util.ArrayList;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

import uiml.android.elements.UimlElementWithAttributes;

public class Presentation extends UimlElementWithAttributes{
	
	// TODO comment
	private ArrayList<DClass> dclasses = new ArrayList<DClass>();
	
	private String base = null;
	private Vocabulary voc = null;

	// TODO comment
	public static String IAM = "presentation";
	public final String DCLASS = "d-class";
	public final String BASE = "base";
	
	/**
	 * 
	 * @param node
	 */
	public Presentation(Element node) {
		super(node);
		process();
	}

	/**
	 * 
	 */
	@Override
	protected Object clone() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/**
	 * 
	 */
	@Override
	public void processElement(Element elem) {

		if(elem.getTagName().equals(DCLASS))
			dclasses.add(new DClass(elem));
	}
	
	/**
	 * 
	 */
	@Override
	public void processAttributes() {
		
		super.processAttributes();
		
		NamedNodeMap attributes = node.getAttributes();
		
		if(attributes != null) {
			if(attributes.getNamedItem(BASE) != null) {
				setBase(attributes.getNamedItem(BASE).getNodeValue());
				
				// TODO elegantere oplossing voor vinden
				if(getIdentifier() == null) 
					setVoc(new Vocabulary(base));
			}			
		}

	}
	
	/**
	 * 
	 * @return
	 */
	public ArrayList<DClass> getComponents() {
		return dclasses;
	}

	/**
	 * 
	 * @param components
	 */
	public void setComponents(ArrayList<DClass> classes) {
		this.dclasses = classes;
	}

	/**
	 * @param base the base to set
	 */
	public void setBase(String base) {
		this.base = base;
	}

	/**
	 * @return the base
	 */
	public String getBase() {
		return base;
	}

	/**
	 * @param voc the voc to set
	 */
	public void setVoc(Vocabulary voc) {
		this.voc = voc;
	}

	/**
	 * @return the voc
	 */
	public Vocabulary getVoc() {
		return voc;
	}	

}
